//package com.yunhe.device.controller.base;
//
//import com.yunhe.device.domain.base.AnalogStatus;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.base.AnalogStatusService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Optional;
//
///**
// * 点表状态Controller
// * @author liuronglei
// */
//@Api(value = "analogStatus", description = "点表状态维护", tags = {"Base_AnalogStatus"})
//@RestController
//@RequestMapping("/statuses/analog")
//public class AnalogStatusController {
//
//    @Autowired
//    private AnalogStatusService analogStatusService;
//
//    /**
//     * 新增点表状态
//     * @param analogStatus 点表状态对象
//     */
//    @ApiOperation("新增点表状态")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody AnalogStatus analogStatus)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        AnalogStatus newAnalogStatus = analogStatusService.createAnalogStatus(analogStatus);
//        return new ResponseEntity<>(new ResultObject<>(newAnalogStatus), HttpStatus.OK);
//    }
//
//    @ApiOperation("批量新增点表状态")
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody DomainList<AnalogStatus> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        List<AnalogStatus> analogStatusList = domainList.getList();
//        List<AnalogStatus> results = analogStatusService.createAnalogStatus(analogStatusList);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除点表状态
//     * @param id 点表状态ID
//     */
//    @ApiOperation("根据ID删除点表状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "点表状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        analogStatusService.deleteAnalogStatus(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新点表状态
//     * @param id 点表状态ID
//     * @param analogStatus 点表状态对象
//     */
//    @ApiOperation("更新点表状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "点表状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody AnalogStatus analogStatus)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        analogStatus.setId(id);
//        AnalogStatus newAnalogStatus = analogStatusService.updateAnalogStatus(analogStatus);
//        return new ResponseEntity<>(new ResultObject<>(newAnalogStatus), HttpStatus.OK);
//    }
//
//    /**
//     * 更新点表状态
//     * @param id 点表状态ID
//     * @param code 点表状态代码
//     * @param name 点表状态编号
//     * @param title 点表状态名称
//     * @param sn 排序序号
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新点表状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "点表状态ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "点表状态代码", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "点表状态编号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "点表状态名称", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "val", value = "状态值", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "sn", value = "排序序号", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("code") Optional<Long> code,
//            @RequestParam("name") Optional<String> name,
//            @RequestParam("title") Optional<String> title,
//            @RequestParam("val") Optional<Long> val,
//            @RequestParam("sn") Optional<Long> sn,
//            @RequestParam("activity") Optional<Boolean> activity)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        AnalogStatus newAnalogStatus = analogStatusService.updateAnalogStatus(id, code.orElse(null),
//                name.orElse(null), title.orElse(null), val.orElse(null),
//                sn.orElse(null), activity.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newAnalogStatus), HttpStatus.OK);
//    }
//
//    /**
//     * 根据点表状态ID获得点表状态
//     * @param id 点表状态ID
//     */
//    @ApiOperation("根据点表状态ID获得点表状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "点表状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        AnalogStatus analogStatus = analogStatusService.findByAnalogStatusId(id);
//        return new ResponseEntity<>(new ResultObject<>(analogStatus), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得点表状态列表
//     */
//    @ApiOperation("根据条件获得点表状态列表")
//
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(@PathVariable("systemId") Long systemId) {
//        Iterable<AnalogStatus> results = analogStatusService.findAnalogStatus();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
////    @ApiOperation("根据条件获得点表状态列表")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path")
////    })
////    @RequestMapping(value = "/byPointNumber/{pointNumber}", method = RequestMethod.GET)
////    public ResponseEntity<ResultObject> findByPointNumber(
////                                                          @PathVariable("pointNumber") Long pointNumber) {
////        Iterable<AnalogStatus> results = analogStatusService.findByPointNumber(pointNumber);
////        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
////    }
//
//    /**
//     * 获得所有点表状态
//     */
//    @ApiOperation("获得所有点表状态")
//
//    @RequestMapping(value = "/all", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findAll(@PathVariable("systemId") Long systemId) {
//        Map<Long, Map<Long, String>> results = analogStatusService.findAll();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据代码绑定点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "pointDataTypeCode", value = "点号数据类型代码", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/bindPointDataTypeByCode", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindPointDataTypeByCode(
//            @RequestParam("code") Long code,
//            @RequestParam("pointDataTypeCode") Long pointDataTypeCode) {
//        analogStatusService.bindPointDataTypeByCode(code, pointDataTypeCode);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 根据点号和点号值列表获得点表值枚举列表
//     * @param pointNumber 点号
//     * @param valueList 点号值列表
//     */
//    @ApiOperation("根据点号和点号值列表获得点表值枚举列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "pointNumber", value = "点号", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "valueList", value = "点号值列表（以逗号间隔）", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/analogStatusTitle", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findAnalogStatusTitle(
//            @RequestParam("pointNumber") Long pointNumber,
//            @RequestParam("valueList") List<Double> valueList) {
//        List<String> result = analogStatusService.findAnalogStatusTitle(pointNumber, valueList);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
////    @ApiOperation("根据代码获得绑定点号数据类型")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "long", paramType = "query"),
////            @ApiImplicitParam(name = "pointDataTypeCode", value = "点号数据类型代码", required = true, dataType = "long", paramType = "query")
////    })
////    @RequestMapping(value = "/byPointNumber/{pointNumber}", method = RequestMethod.GET)
////    public ResponseEntity<ResultObject> getAnalogStatus(
////                                                        @PathVariable("pointNumber") Long pointNumber) {
////        String result = analogStatusService.getAnalogStatus(systemId, pointNumber);
////        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
////    }
//
//}
